.pragma library

var _isDebug = true;
var _logCountMax = 10;


//デバッグ出力
function outputDebugString(text) {
    if(_isDebug){
        console.debug(text);
    }
}

// ウエイトを入れる
function delay(msec){
    var start = 0;
    start = new Date();
    do{
        now = new Date();
    }while((now - start) < msec);
}


// ログをリストへ出力
function outputLog(model, text, from_worker){
    if(from_worker === undefined){
        from_worker = true;
    }
    if((model === null) || (model === undefined)){
    }else{
        var now_string = Qt.formatDateTime(new Date(), "yyyy-MM-dd hh:mm:ss");

        model.append({"_message": now_string + " > " + text});
        // model.insert(0, {"_message": now_string + " > " + text});

        model.sync();
    }
}


// 文字列配列から１つをランダムに選ぶ
function selectOne(list){
    var ret = "";
    if((list === null) || (list === undefined)){
        //error
    }else{
        var size = list.length;
        var index = parseInt(Math.random() * (size - 1));
        ret = list[index];
    }
    return ret;
}
